package com.bnlr.lrparking.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bnlr.lrparking.R;
import com.bnlr.lrparking.model.ParkM;
import com.bnlr.lrparking.model.TopUpM;
import com.yolanda.nohttp.rest.Request;

import java.util.ArrayList;
import java.util.List;

/**
 * 车位的adapter
 *
 * @author rr
 * @date 2016/7/2
 */
public class CarPlaceAdapter extends BaseAdapter {

    public Request<String> mRequest;
    private Context mcontext;
    private List<ParkM.DataBean> list;
    private LayoutInflater inflater;

    public CarPlaceAdapter(Context context, List<ParkM.DataBean> list) {
        super();
        this.mcontext = context;
        this.list = list;
        inflater = LayoutInflater.from(mcontext);
    }

    @Override
    public int getCount() {
        if (list != null) {
            return list.size();
        }
        return 0;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        final ViewHoder hoder;
        if (convertView == null) {
            hoder = new ViewHoder();
            convertView = inflater.inflate(R.layout.item_park, null);
            hoder.carplace_number_num = (TextView) convertView.findViewById(R.id.carplace_number_num);
            hoder.stall_check = (TextView) convertView.findViewById(R.id.stall_check);
            convertView.setTag(hoder);
        } else {
            hoder = (ViewHoder) convertView.getTag();
        }
        final ParkM.DataBean bean = list.get(i);
        // hoder.carplace_number_num.setText(bean.getType());
        hoder.stall_check.setText(bean.getNumber());
        return convertView;
    }

    class ViewHoder {
        TextView carplace_number_num, stall_check;
    }
}
